/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.util;

import br.com.deployment.entidade.protocolo.ServicoProtocolo;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author roniere
 */
public class ServicoProtocoloModel extends ListDataModel<ServicoProtocolo> implements SelectableDataModel<ServicoProtocolo>{

    public ServicoProtocoloModel() {
        super();
    }

    public ServicoProtocoloModel(List<ServicoProtocolo> list) {
        super(list);
        System.err.println("Teste" + list);
    }
      
    @Override
    public Object getRowKey(ServicoProtocolo t) {
        System.err.println("RowKey" + t);
        return t.getId();
    }

    @Override
    public ServicoProtocolo getRowData(String string) {
        System.err.println("RowDate" + string);
         List<ServicoProtocolo> servP = (List<ServicoProtocolo>) getWrappedData();  
          
        for(ServicoProtocolo sp : servP) {  
            if(sp.getId() == Integer.parseInt(string))  
                return sp;  
        }  
          
        return null; 
    }
    
}
